package edu.pku.sandbox
{
	import flash.utils.Dictionary;
	
	import mx.collections.ArrayCollection;
	
	public class HistoryDataManager
	{
		public var allHisData:Dictionary=new Dictionary();
		public function HistoryDataManager()
		{
			
		}
		
		public function addHistoryData(id:String,data:SensorHistoryData)
		{
			var hisdata:HistoryData=allHisData[id] as HistoryData;
			if(hisdata==null)
			{
				hisdata=new HistoryData();
				allHisData[id]=hisdata;
			}
			hisdata.update(data);
		}
		
		public function getHistoryDataById(id:String)
		{
			return allHisData[id];
		} 
		
	}
	
	class HistoryData
	{
		public var static int MAX_RECORDS=100;
		
		public var hisRecords:ArrayCollection=new ArrayCollection();
		public var id:String
		public var type:int;
		
		public var update(historyData:SensorHistoryData):void
		{
			if (hisRecords.length > MAX_RECORDS)
			{
					hisRecords.removeItemAt(0);
			}
			hisRecords.addItem(historyData);
		}
	}
}